//
//  TestSJPlayerController.m
//  ProjectDemo
//
//  Created by IOS3 on 2018/11/14.
//  Copyright © 2018 IOS3. All rights reserved.
//

#import "TestSJPlayerController.h"
#import <SJVideoPlayer.h>

@interface TestSJPlayerController ()

@property (nonatomic, strong) SJVideoPlayer *player;

@end

@implementation TestSJPlayerController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self installPlayer];
}


- (void)installPlayer {
    self.player = [SJVideoPlayer player];
    self.player.view.frame = CGRectMake(0, CGRectGetMaxY(self.navigationController.navigationBar.frame),
                                        SCREEN_WIDTH, SCREEN_WIDTH *  9 / 16);
    [self.view addSubview:self.player.view];
    NSURL *url = [NSURL URLWithString:@"https://www.apple.com/105/media/us/iphone-x/2017/01df5b43-28e4-4848-bf20-490c34a926a7/films/feature/iphone-x-feature-tpl-cc-us-20170912_1280x720h.mp4"];
    
    SJVideoPlayerURLAsset *asset = [[SJVideoPlayerURLAsset alloc] initWithURL:url];
    asset.title = @"视频标题 #wtf#";
    asset.alwaysShowTitle = true;
    
    self.player.URLAsset = asset;
    
    // 设置支持的方向
    // self.player.supportedOrientation =
}


- (void)refresh {
    [self.player refresh];
}
- (void)playerDealloc {
    // 资源 dealloc 的回调
    self.player.assetDeallocExeBlock = ^(__kindof SJBaseVideoPlayer * _Nonnull videoPlayer) {
        
    };
}

/*
 /// 相同资源在不同页面间连续播放
 // 新界面的播放器, 资源初始化:
 _videoPlayer = [SJVideoPlayer player];
 _videoPlayer.view.frame = CGRectMake(0, 20, 375, 375 * 9/16.0); // 可以使用AutoLayout, 这里为了简便设置的Frame.
 [self.view addSubview:_videoPlayer.view];
 // 初始化资源
 _videoPlayer.URLAsset = [SJVideoPlayerURLAsset initWithOtherAsset:otherAsset playModel:[SJPlayModel playModel....];
 */

@end
